SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[veiculoTipoInsert]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'

CREATE PROCEDURE spVeiculoTipoInsert
(
	@NomeTipo Varchar(100)	
)
AS

INSERT veiculoTipo 
(
	
	vet_nome
) 
	VALUES 
(
	
	@NomeTipo
)
' 
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[veiculoTipoSelect]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'
CREATE PROCEDURE spVeiculoTipoSelect
(
	@Id Int
)
AS
SELECT
	vet_id,	
	vet_nome	
FROM
	veiculoTipo
WHERE 
	vet_id = @Id
' 
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[veiculoTipoUpdate]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'
CREATE PROCEDURE spVeiculoTipoUpdate
(
	@Id Int,
	@NomeTipo Varchar(100)	
)
AS
UPDATE veiculoTipo SET
	vet_nome = @NomeTipo
	
WHERE vet_id = @Id
' 
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[veiculoTipoSelectAll]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'
CREATE PROCEDURE spVeiculoTipoSelectAll
	
AS   SELECT vet_id, vet_nome FROM  dbo.veiculoTipo
ORDER BY vet_nome
	SET NOCOUNT ON 
	RETURN
' 
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[veiculoTipoDelete]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'
CREATE PROCEDURE spVeiculoTipoDelete
(
	@Id Int
)
AS
DELETE 
	veiculoTipo 
WHERE 
	vet_id=@Id
' 
END
